using UnityEngine;
using Yoozoo.Managers.ResourceManagerV2.Framework.Resource;
using Yoozoo.Managers.ResourceManagerV2.Runtime;
using Object = UnityEngine.Object;

namespace Yoozoo.Mars.Got
{
    
    public delegate void LoadObjectCompleteHandler(UnityEngine.Object obj);

    public static class ResourceFunc
    {
        public static string AssetsRoot = "Assets/ResourcesAssets/";
        
        public static void LoadBytesAsync(string path, LoadObjectCompleteHandler handler)
        {
            path = string.Format("{0}{1}{2}", AssetsRoot, path, ".bytes");
            UMTResource.LoadAsset(path, (string assetName, object asset, float duration, object userData) =>
            {
                handler.Invoke(asset as Object);
            }, (string assetName, LoadResourceStatus status, string errorMessage, object userData) =>
            {
                Debug.LogErrorFormat("asset:{0} failed :{1}", assetName, errorMessage);
            });
        }
    }
}